<template>
  <div class="conetnt-page">
    <div class="banner">
      <img class="bannerimg" src="http://serve.wczw.top/1620198068888.jpg">
      <div class="posMeng flex-center">
        <div class="box">
          <div class="name">Avia</div>
          <div class="text">出发之前永远是梦想，上路之后永远是挑战</div>
        </div>
      </div>
      <div class="pointer-wrap" @click="scrollDown()">
        <img class="xiala" src="@/assets/xiala.png" />
      </div>
    </div>
    <div class="content">
      <div class="article-list">
        <div @click="toDetail(item.bid)" v-for=" (item,index) in listData" :key="index" class="article-item">
          <h4 class="title">{{item.title}}</h4>
          <div class="desc tline4">{{item.dsc}}</div>
          <div class="time">
            <span class="author">{{item.author}}</span>|<span class="str">{{item.createTime}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getList } from "@/api/index.js";
export default {
  data() {
    return {
      listData: [],
      listQuery: {
        page: 1,
        size: 20,
        cId: "",
      },
      isDoing: false,
      isOver: false,
    };
  },
  mounted() {
    this.getScroolList();
    window.scrollTo(0,0)
    window.addEventListener("scroll", () => {
      var scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop;
      //变量windowHeight是可视区的高度
      var windowHeight =
        document.documentElement.clientHeight || document.body.clientHeight;
      //变量scrollHeight是滚动条的总高度
      var scrollHeight =
        document.documentElement.scrollHeight || document.body.scrollHeight;
      //滚动条到底部的条件
      if (scrollTop + windowHeight >= scrollHeight) {
        console.log('tag', '')
        this.getScroolList();
      }
    });
  },
  methods: {
    scrollDown() {
      window.scrollTo(0, 800);
    },
    getBList(params = {}) {
      return new Promise((reslove, reject) => {
        getList(params).then((res) => {
          reslove(res.data);
        });
      });
    },
    getScroolList() {
      if (this.isDoing || this.isOver) return;
      this.isDoing = true;
      this.getBList(this.listQuery).then((res) => {
        this.listQuery.page++;
        this.isDoing = false;
        this.isOver = res.data.length < this.listQuery.size;
        this.listData = [...this.listData, ...res.data];
      });
    },
    toDetail(bid) {
      this.$router.push({
        path: "/detail",
        query: { bid },
      });
    },
  },
  computed: {},
};
</script>

<style lang="scss" scoped>
.conetnt-page {
  .banner {
    position: relative;
    width: 100%;
    font-family: -apple-system,BlinkMacSystemFont,segoe ui,roboto,oxygen,ubuntu,cantarell,fira sans,droid sans,helvetica neue,sans-serif;
    font-size: 0px;
    .posMeng {
      position: absolute;
      top: 0px;
      left: 0px;
      width: 100%;
      height: 100%;
      text-align: center;
      color: #fff;
      background-color: rgba(0, 0, 0, 0.2);
      .name {
        font-size: 45px;
        font-weight: 900;
        animation: fade-in-down .6s both;
        animation-delay: .81s;
        margin-bottom: 5px;
      }
      .text {
        color: #f8f8f8;
        font-size: 17px;
        animation: fade-in-down 0.9s both;
        animation-delay: 1.1s;
        letter-spacing: 2px;
        text-shadow: 10px 10px 20px rgba(0, 0, 0, 1);
      }
    }
    .bannerimg {
      width: 100%;
      height: auto;
      min-height: 200px;
      max-height: 100vh;
      opacity: 0;
      animation: fadeIn 1.5s ease-out forwards;
    }
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1;}
    }
    @keyframes fade-in-down {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    @keyframes bounce {
        0%, 10%, 25%, 40%, 50% { transform: translateY(0); }
        20% { transform: translateY(-10px); }
        30% { transform: translateY(-5px); }
    }
    .pointer-wrap {
        position: absolute;
        color: rgba(255, 255, 255, 0.7);
        font-size: 34px;
        width: 34px;
        left: 50%;
        margin-left: -17px;
        bottom: 45px;
        text-align: center;
        animation: bounce 4s 2s infinite;
        transition: color .3s ease;
        cursor: pointer;
        &:hover {
            color: #fff;
        }
        img{
          width: 100% !important;
          max-height: auto !important;
          max-height: auto !important;
        }
    }   
    @keyframes bounce {
        0%, 10%, 25%, 40%, 50% { transform: translateY(0); }
        20% { transform: translateY(-10px); }
        30% { transform: translateY(-5px); }
    }
    @media only screen and (max-width: 1024px) {
      .pointer-wrap {
          display: none;
      }
    }
  }
  .content {
    width: 100%;
    max-width: 810px;
    padding: 0px 20px;
    margin: 0 auto;
    padding-bottom: 100px;
    .article-list {
      .article-item {
        margin-top: 60px;
        padding-bottom: 40px;
        border-bottom: 1px solid #ebf2f6;
        .title {
          font-size: 38px;
          line-height: 1.5;
          color: #4a4a4a;
        }
        .desc {
          font-size: 15px;
          color: #444;
          margin-top: 10px;
        }
        .time {
          font-size: 13px;
          color: #8492a6;
          margin-top: 10px;
          .author {
            margin-right: 12px;
          }
          .str {
            margin-left: 12px;
          }
        }
      }
    }
  }
}
@media screen and(max-width:720px) {
  .conetnt-page {
    .content {
      .article-list {
        .article-item {
          margin-top: 40px;
          .title {
            font-size: 26px;
          }
        }
      }
    }
  }
}
</style>
